<style media="print">
    @page {
      size: auto;  /* auto is the initial value */
      margin: 0mm; /* this affects the margin in the printer settings */
    }
     .noprint{visibility:hidden}
</style>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  <legend>收货人信息</legend>
</fieldset>
<table class="layui-table">
    <tbody>
      <tr>
        <td width="8%">收货人姓名</td><td><{$name}></td>
      </tr>
    <tr>
      <td>收货人电话</td><td><{$phone}></td>
    </tr>
      <tr>
        <td>收货人地址</td><td><{$address}></td>
      </tr>
    </tbody>
  </table>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
  <legend>发货清单</legend>
</fieldset>
<table class="layui-table">
    <thead>
      <tr>
        <th width=25>订单ID</th>
        <th>名称</th>
        <th>规格</th>
        <th>单价</th>
        <th>数量</th>
        <th>发货状态</th>
      </tr>
    </thead>
    <tbody>
      <{volist name='list' id='v'}>
        <tr>
          <td><{$v['order_goods_id']}></td>
          <td><{$v['title']}></td>
          <td><{$v['spec']}></td>
          <td><{$v['price']}></td>
          <td><{$v['num']}></td>
          <td id='detail_<{$v['id']}>'><{if $v['status']}>已发货<{else}>
              <input type="checkbox" name="id[]" value="<{$v['id']}>" />
              <{/if}></td>
        </tr>
      <{/volist}>
    </tbody>
  </table>

<fieldset class="noprint layui-elem-field layui-field-title" style="margin-top: 50px;">
  <legend>填写快递号</legend>
</fieldset>
<form class="noprint layui-form" action="" onsubmit="return false;">
    <div classiv class="layui-form-item">
        <label class="layui-form-label">快递公司</label>
      <div class="layui-input-block">
        <select name="express_mb_id">
          <option value="">请选择快递公司</option>
          <{volist name='express' id='v'}>
          <option value="<{$v['id']}>"><{$v['name']}></option>
          <{/volist}>
        </select>
      </div>
    </div>
  <div class="layui-form-item">
    <label class="layui-form-label">快递单号</label>
    <div class="layui-input-block">
      <input type="text" name="kd_no" placeholder="请输入快递单号 输入0000不验证" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">发货备注</label>
    <div class="layui-input-block">
      <textarea name="note" placeholder="请输入发货备注" class="layui-textarea"></textarea>
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" onclick="fahuo()">立即提交</button>
      <a class="layui-btn" href="javascript:window.print()">打印</a>
    </div>
  </div>
</form>

<script>
$().ready(function(){
  layui.form.render('select');
});
//发货
function fahuo(){
    var ids = [];
    $("[name='id[]']:checked").each(function(i,e){
        ids.push($(e).val());
    });
    if( ids.length==0 ){
        layui.layer.msg("请勾选发货的产品");
        return false;
    }
    var note = $('[name="note"]').val();
    var kd_no = $('[name="kd_no"]').val();
    var express_mb_id = $('[name="express_mb_id"]').val();
    if ( express_mb_id == '' ) { layui.layer.msg('请选择物流公司',{icon:5});return;}
    if ( kd_no == '' ) { layui.layer.msg('请填写快递单号',{icon:5});return;}
    if ( note == '' ) { layui.layer.msg('请输入备注信息',{icon:5});return;}

    layui.layer.confirm('您确定要对该订单发货？', {
        btn: ['确定','取消'] //按钮
    }, function(){
        var url  = "<{:url('sendgoods/fahuo')}>";
        var post = {ids:ids,kd_no:kd_no,express_mb_id:express_mb_id,note:note};
        _ajax(url, post);
    });
}
</script>
